package com.guonl.mybatis;

import com.guonl.mybatis.interceptor.ReplaceQueryColumnInterceptor;
import com.guonl.mybatis.interceptor.SqlLogInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * mybatis配置
 */
@Configuration
public class MybatisConfiguration {


    @Bean
    public SqlLogInterceptor logInterceptor() {
        SqlLogInterceptor interceptor = new SqlLogInterceptor();
        Properties properties = new Properties();
        // 设置是否显示数据库执行语句的执行时间
        properties.setProperty(SqlLogInterceptor.PROPERTIES_KEY_ENABLE_EXECUTOR_TIME, SqlLogInterceptor.ENABLE_EXECUTOR_TIME);
        interceptor.setProperties(properties);
        return interceptor;
    }

    @Bean
    public ReplaceQueryColumnInterceptor replaceQueryColumnInterceptor() {
        return new ReplaceQueryColumnInterceptor();
    }




}
